package com.weseal.dry;

import com.weseal.dry.config.RootConfig;
import com.weseal.dry.config.WebConfig;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MockMvcBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

/**
 * @title
 * @description
 * @usage
 * @copyright Copyright 2014  rrmj Corporation. All rights reserved.
 * @company 上海众多美网络科技有限公司
 * @author weseal
 * @create 2018/3/28
 */
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration(value = "/src/main/webapp")
@ContextHierarchy({
		@ContextConfiguration(name="parent",classes = RootConfig.class),
		@ContextConfiguration(name = "child" , classes = WebConfig.class)
})
public abstract class BaseMock {

	@Autowired
	protected WebApplicationContext context;
	protected MockMvc mockMvc;

	@Before
	public void init(){
		 mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
	}

}
